<template>
	<view v-if="info.courseName" :style="theme">
		<view style="height: 20rpx;"></view>
		<view v-if="flag == 1" class="box">
			<image mode="widthFix" :src="imgHost+'/ic_success.png'"></image>
			<view class="box_font">签到成功</view>
			<view class="cnt">
				<view class="name">
					{{info.courseName}}
				</view>
				<view>上课时间：{{info.timeInfo}}</view>
				<view>课程时长：{{info.courseType=='4'?formatSeconds(info.duration):info.classNum?info.classNum: 0}}{{info.courseType=='4'?'':'课时'}}</view>
				<view>上课地点：{{info.site}}</view>
				<view>上课老师：{{info.teacherName || ''}}</view>
				<view>签到学员：<block v-for="(item, index) in info.students" :key="index">{{item.status =='1'?item.name:''}}</block></view>
			</view>
		</view>
		<view v-else class="box">
			<image mode="widthFix" :src="imgHost+'/ic_fail.png'"></image>
			<view class="box_font">签到失败</view>
			<view class="f26 c9 mt20">
				不在可签到时间范围内
			</view>
			<view class="btn">
				重新扫码
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				flag: 1,
				id: '',
				info: {}
			}
		},
		onLoad(ops) {
			console.log(12312, ops)
			let flag = ops.flag || 1
			this.flag = flag
			this.id = ops.id || ''
			// if(flag == 1) {
			// 	this.getDetail()
			// }
			this.getDetail()
		},
		methods: {
			jump(url, params, a) {
				this.$app.jump(url, params, a);
			},
			jump2(url, params, a) {
				this.$app.jump2(url, params, a);
			},
			formatSeconds(e) {
			   return this.$app.formatSeconds(e);
			},
			getDetail() {
				this.$app.ajax({
					api: this.$api.myCourseDetail(),
					data: {
						param: {
							memberId: this.userInfo.id,
							venueId: this.venueId,
							timeId: this.id,
							showTag: '1'
						}
					}
				}).then((res) => {
					if (res.errorCode === '000000') {
						this.info = res.record
					}
				}).catch(() => {})
			},

		}

	}
</script>


<style scoped lang="scss">
	.box {
		display: flex;
		align-items: center;
		flex-direction: column;
		width: 690rpx;
		margin: auto;
		height: calc(100vh - 40rpx);
		box-sizing: border-box;
		background: #FFFFFF;
		border-radius: 8rpx;
		padding: 164rpx 40rpx 0;

		image {
			width: 180rpx;
			height: 180rpx;
		}

		.box_font {
			font-size: 36rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: bolder;
			color: #222222;
			margin-top: 40rpx;
		}

		.cnt {
			background: #F7F7F7;
			border-radius: 8rpx;
			width: 100%;
			margin-top: 60rpx;
			box-sizing: border-box;
			padding: 30rpx;

			view {
				font-size: 26rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				margin-top: 20rpx;
				color: #666666;

				&.name {
					font-size: 30rpx;
					color: #222222;
					margin-top: 0;
				}
			}
		}
		.btn {
			width: 100%;
			line-height: 88rpx;
			margin-top: 80rpx;
			background: $color;
			border-radius: 50rpx;
			font-size: 30rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: Medium;
			text-align: center;
			color: #FFFFFF;
		}
	}
</style>